package com.tracesystem.controller.info;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;
@Data
public class UserInfo implements UserDetails {

    @TableId(value = "USER_ID", type = IdType.AUTO)
    private Integer userId;

    @TableField("PASSWORD")
    private String password;

    @TableField("USERNAME")
    private String username;

    @TableField("ROLE_ID")
    private Integer roleId;

    @TableField("USER_TEL")
    private String userTel;

    @TableField("USER_EMAIL")
    private String userEmail;

    private List<GrantedAuthority> roles;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return roles;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
